import { defineStore } from "pinia";
import { ref } from "vue";

const KEY = "view-config";

/**
 * 视图配置
 */
export const useViewConfigStore = defineStore(KEY, () => {
  const config = ref([] as Array<any>);

  function set(configJson: any) {
    config.value = configJson;
  }

  function get(code: string) {
    return config.value.filter((item) => item.code === code).pop();
  }

  return {
    set,
    get,
  };
});
